try:
    from threading import local
except ImportError:
    from django.utils._threading_local import local

_thread_locals = local()
def get_current_sub():
    return getattr(_thread_locals, 'subcategoria', None)

def get_current_categoria():
    return getattr(_thread_locals, 'categoria', None)

class ThreadLocals(object):
    def process_request(self, request):
        _thread_locals.subcategoria = getattr(request, 'subcategoria', None)
        _thread_locals.categoria = getattr(request.POST["categoria"], 'categoria', None)
